from rest_framework import serializers

from apps.career.models import Careerplan
from apps.career.serializers import UsersSerializer
from apps.message.models import Comments, Message
from apps.resume.serializers import ResumeSerializers
from apps.setup.serializers import ExpertsSerializers


class MessageSerializers(serializers.ModelSerializer):
    create_time = serializers.DateTimeField('%Y-%m-%d %H:%M:%S')
    from_field = UsersSerializer()

    class Meta:
        model = Message
        fields = "__all__"


class CareerSerializer(serializers.ModelSerializer):
    class Meta:
        model = Careerplan
        fields = ('careerplan_id', 'title', 'status')


class CommentsSerializers(serializers.ModelSerializer):
    create_time = serializers.DateTimeField('%Y-%m-%d %H:%M:%S')
    careerplan_id = CareerSerializer()
    experts_id = ExpertsSerializers()
    resume_id = ResumeSerializers()
    user_id = UsersSerializer()

    class Meta:
        model = Comments
        fields = (
            'careerplan_id', 'comments_id', 'content', 'create_time',
            'is_author', 'status', 'resume_id', 'user_id', 'experts_id'
        )
